﻿Imports System.Data.Linq
Imports System.Linq
Imports TNCDAL

Public Class MBLController
    Private objRepository As New MBLRepository

    Public Function GetCustomMBLList() As IQueryable
        Dim MBLs As IQueryable = From p In objRepository.GetMBLList()
                    Select p.ID_MBL, _
                                     p.MBLNo, _
                                     p.tblVoyage.VoyageNo, _
                                     p.tblVoyage.tblLine.LineName, _
                                     p.tblVoyage.tblVessel.VesselName, _
                                     POL = p.tblVoyage.tblPort.Port, _
                                     POD = p.tblVoyage.tblPort1.Port, _
                                     p.tblVoyage.ETA, _
                                     p.tblVoyage.ETD

        Return MBLs
    End Function

    
    Public Function GetRemainMBLList(ByVal isExport As Boolean, ByVal id_File As Integer) As IQueryable(Of tblMBL)
        Return objRepository.GetRemainMBLList(isExport, id_File)
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblMBL
        Return objRepository.SelectRecordById(id)
    End Function

    Public Function Insert(ByVal objMBL As tblMBL) As tblMBL
        objMBL = objRepository.Insert(objMBL)
        Return objMBL
    End Function

    Public Sub Update(ByVal objMBL As tblMBL)
        objRepository.Update(objMBL)
    End Sub

    Public Function SelectMBLByMBLNo(ByVal strMBLNo As String) As tblMBL
        Return objRepository.SelectMBLByMBLNo(strMBLNo)
    End Function

    Public Function SelectMBLByInfo(ByVal objMBL As tblMBL) As tblMBL
        Return objRepository.SelectMBLByInfo(objMBL)
    End Function


    Public Sub RemoveMBLByFile(ByVal id_File As Integer, ByVal objMBL As tblMBL)
        objRepository.RemoveMBLByFile(id_File, objMBL)
    End Sub
End Class
